<template>
	<view>
		<!-- 自定义导航栏 -->
		<uni-nav-bar left-icon="arrowleft"  @clickLeft="back" :statusBar="true" rightText="发布" @clickRight="submit">
			<view class="u-f-ajc" @tap="changelook">
				<!-- 图标，后续补充 -->
				
				{{yinsi}}
				<view class="icon iconfont icon-xialazhankai"></view>
				
			</view>
		</uni-nav-bar>
		<!-- 多行输入框-->
		<view class="uni-textarea">
			<textarea  placeholder="发个说说吧~" v-model="text" />
		</view>
		<!-- 上传多图 -->
	    <upload-images @uploud="uploud"></upload-images>
		<!-- 弹出公告 -->
		<uniPopup ref="showPopup" type="center" :maskClick="false">
					<view class="the_popup">
						<view class="flex-row">
							<image src="../../static/none/popup.png" mode="widthFix" class="myimg"></image>
						</view>
						<view class="mt5 flex-row" style="color: #f2b640;">
							严禁发表以下信息
						</view>
						<view class="color-333-size-14 mt5">1、涉及黄色，政治，广告及骚扰信息</view>
						<view class="color-333-size-14">2、涉及人身攻击</view>
						<view class="color-333-size-14">3、留联系方式，透露他人隐私</view>
						<view class="color-333-size-14">一经核实将被封禁，情节严重者永久封禁</view>
						<button type="primary" class="mt10" @tap="closeTap">朕知道了</button>
					</view>
				</uniPopup>
		
	</view>
</template>

<script>
	let changelook=['所有人可见','仅自己可见'];
	import uniNavBar from "../../components/uni-nav-bar/uni-nav-bar.vue";
	import uploadImages from "../../components/commom/upload-images.vue";
	import uniPopup from "../../components/uni-popup/uni-popup.vue";
	
	export default {
		components:{
			uniNavBar,
			uploadImages,
			uniPopup
		},
		data() {
			return {
				yinsi:'所有人可见',
				text:'',
				imglist:[],
				showpopup:true,
				isget:false
				
			}
		},
		onBackPress() {
			//如果有值
			if(!this.text && this.imglist.length<1){
				return;
			}
			if(!this.isget){
				this.baocun();
		    
				return true;
			}
		},
		mounted(){
				this.open()
			},
		methods: {
			//保存为草稿
			baocun(){
				uni.showModal({
						content:'是否要保存为草稿',
						cancelText:'不保存',
						confirmText:'保存',
						success: (res) => {
							if(res.confirm){
								console.log('保存')
							}else{
								console.log('不保存')
							}
							this.isget=true;
							uni.navigateBack({
								delta: 1
							})
						}
					
				})
			},
			open(){
				this.$refs.showPopup.open()
				},
			closeTap() {
				this.$refs.showPopup.close()
				},
			back(){
				uni.navigateBack({
					delta: 1
				})
			},
			//发布事件
			submit(){
				console.log('发布')
			},
			//隐私
			changelook(){
				uni.showActionSheet({
					itemList:changelook,
					success:(res)=>{
						this.yinsi=changelook[res.tapIndex]
					}
				})
			},
			uploud(arr){
				this.imglist=arr;
				console.log(this.imglist)
			},
			hidePopup(){
				this.showpopup=false;
			}
			
		}
	}
</script>

<style>

.the_popup{
	width: 600upx;
	height: auto;
	padding: 30upx 60upx;
	margin: 0 auto;
	background-color: #FFFFFF;
	border-radius: 20upx;

}

.myimg{
	width: 400upx;
}
button {
			background-color: #ffe934;
			border-color: #ffe934;
			color: #333333;
			font-size: 32upx;
		}
	uni-textarea{
		border: 1upx solid #EEEEEE;
	}
	
	
</style>
